home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wlpprchg / wallchng.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  8.9 KB  |  326 lines

  1. VERSION 2.00
  2. Begin Form WallChng 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Wall Change"
  6.    ClientHeight    =   2325
  7.    ClientLeft      =   3120
  8.    ClientTop       =   2655
  9.    ClientWidth     =   2610
  10.    Height          =   2730
  11.    Icon            =   WALLCHNG.FRX:0000
  12.    Left            =   3060
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    Picture         =   WALLCHNG.FRX:0302
  17.    ScaleHeight     =   2325
  18.    ScaleWidth      =   2610
  19.    Top             =   2310
  20.    Width           =   2730
  21.    Begin CommandButton Quit 
  22.       Caption         =   "Quit"
  23.       Height          =   375
  24.       Left            =   1416
  25.       TabIndex        =   6
  26.       Top             =   1068
  27.       Width           =   735
  28.    End
  29.    Begin CommandButton About 
  30.       Caption         =   "About"
  31.       Height          =   375
  32.       Left            =   372
  33.       TabIndex        =   5
  34.       Top             =   1068
  35.       Width           =   735
  36.    End
  37.    Begin ComboBox Combo1 
  38.       BackColor       =   &H000000FF&
  39.       ForeColor       =   &H00FF0000&
  40.       Height          =   300
  41.       Left            =   510
  42.       TabIndex        =   0
  43.       Text            =   "Combo1"
  44.       Top             =   570
  45.       Width           =   1530
  46.    End
  47.    Begin Timer Timer5 
  48.       Interval        =   1315
  49.       Left            =   1440
  50.       Top             =   0
  51.    End
  52.    Begin Timer Timer4 
  53.       Interval        =   1210
  54.       Left            =   1080
  55.       Top             =   15
  56.    End
  57.    Begin Timer Timer3 
  58.       Interval        =   1105
  59.       Left            =   705
  60.       Top             =   0
  61.    End
  62.    Begin Timer Timer2 
  63.       Interval        =   1000
  64.       Left            =   375
  65.       Top             =   0
  66.    End
  67.    Begin Timer Timer1 
  68.       Left            =   0
  69.       Top             =   0
  70.    End
  71.    Begin Label icon4 
  72.       Caption         =   "icon4"
  73.       DragIcon        =   WALLCHNG.FRX:0AB2
  74.       Height          =   192
  75.       Left            =   2004
  76.       TabIndex        =   4
  77.       Top             =   720
  78.       Visible         =   0   'False
  79.       Width           =   576
  80.    End
  81.    Begin Label icon3 
  82.       Caption         =   "icon3"
  83.       DragIcon        =   WALLCHNG.FRX:0DB4
  84.       Height          =   216
  85.       Left            =   1992
  86.       TabIndex        =   3
  87.       Top             =   468
  88.       Visible         =   0   'False
  89.       Width           =   588
  90.    End
  91.    Begin Label icon2 
  92.       Caption         =   "icon2"
  93.       DragIcon        =   WALLCHNG.FRX:10B6
  94.       Height          =   216
  95.       Left            =   1992
  96.       TabIndex        =   2
  97.       Top             =   240
  98.       Visible         =   0   'False
  99.       Width           =   588
  100.    End
  101.    Begin Label icon1 
  102.       Caption         =   "icon1"
  103.       DragIcon        =   WALLCHNG.FRX:13B8
  104.       Height          =   192
  105.       Left            =   2028
  106.       TabIndex        =   1
  107.       Top             =   0
  108.       Visible         =   0   'False
  109.       Width           =   540
  110.    End
  111. DefInt A-Z
  112. Declare Sub SystemParametersInfo Lib "User" (ByVal wAction%, ByVal wParam%, lParam As Any, ByVal fWinIni%)
  113. Declare Function GetFreeSpace Lib "Kernel" (ByVal wFlags As Integer) As Long
  114. Declare Function GetModuleHandle Lib "Kernel" (ByVal ModName$)
  115. Declare Function GetHeapSpaces& Lib "Kernel" (ByVal hModule)
  116. Declare Function DiskInfo Lib "DiskInfo.DLL" (ByVal DriveNum%, ByVal DriveInfo%) As Long
  117. Dim WallPaperFile As String
  118. Dim Called As String
  119. Dim CapSwitch As String
  120. Dim timeloop As Integer
  121. Dim mem As String
  122. Dim res As String
  123. Dim disk(3 To 5) As String
  124. Dim tim As String
  125. Dim MyTime As String
  126. Dim OldMyTime As String
  127. Dim Hours As Integer
  128. Dim x As Integer
  129. Sub About_Click ()
  130.     ret$ = Chr$(13) + Chr$(10)
  131.     title$ = "About"
  132.     msg$ = "   Wallpaper Changer - Version 8/92" + ret$ + ret$
  133.     msg$ = msg$ + "        By Tim Hitchings (73637,66)" + ret$ + ret$
  134.     msg$ = msg$ + "Special Thanks:  " + ret$
  135.     msg$ = msg$ + "
  136.  The Waite Group's Visual Basic How-To" + ret$
  137.     msg$ = msg$ + "
  138.  Ian Taylor for the DiskInfo.DLL" + ret$
  139.     msg$ = msg$ + "
  140.  Nelson Ford for VB-Tips"
  141.     MsgBox msg$, 0, title$
  142. End Sub
  143. Sub combo1_click ()
  144.   If combo1.text = "30 Minutes" Then
  145.     timer1.interval = 60000
  146.     timeloop = 30
  147.   ElseIf combo1.text = " 5 Minutes" Then
  148.     timer1.interval = 60000
  149.     timeloop = 5
  150.   ElseIf combo1.text = " 1 Minute" Then
  151.     timer1.interval = 60000
  152.   ElseIf combo1.text = "30 Seconds" Then
  153.     timer1.interval = 30000
  154.   ElseIf combo1.text = "10 Seconds" Then
  155.     timer1.interval = 10000
  156.   ElseIf combo1.text = " 1 Second" Then
  157.     timer1.interval = 1000
  158.   ElseIf combo1.text = "PAUSE" Then
  159.     timer1.interval = 0
  160.   End If
  161.   combo1.Refresh
  162.   windowstate = 1
  163. End Sub
  164. Sub DirBMP ()
  165.     Called = "Y"
  166.     Filespec$ = "*.BMP"
  167.     WallPaperFile = Dir$(Filespec$)
  168.     If Len(WallPaperFile) = 0 Then
  169.     title$ = "Fatal Error"
  170.     msg$ = "You must put WALLCHNG.EXE in your WINDOWS DIRECTORY!"
  171.     response% = MsgBox(msg$, 16, title$)
  172.     Unload Wallchng
  173.     End If
  174. End Sub
  175. Sub DirBMP2 ()
  176.     Filespec$ = "*.BMP"
  177.     WallPaperFile = Dir$
  178.     If Len(WallPaperFile) = 0 Then
  179.     DirBMP
  180.     End If
  181. End Sub
  182. Sub Form_Load ()
  183.   combo1.AddItem "PAUSE"
  184.   combo1.AddItem " 1 Second"
  185.   combo1.AddItem "10 Seconds"
  186.   combo1.AddItem "30 Seconds"
  187.   combo1.AddItem " 1 Minute"
  188.   combo1.AddItem " 5 Minutes"
  189.   combo1.AddItem "30 Minutes"
  190.   combo1.text = "30 Minutes"
  191.   timer1.interval = 60000
  192.   timeloop = 30
  193.   windowstate = 1
  194.   ResMemDisk
  195.   Wallchng.caption = mem
  196.   CapSwitch = "1"
  197. End Sub
  198. Function GetFreeResources (ModuleName$)
  199.     rInfo& = GetHeapSpaces&(GetModuleHandle(ModuleName$))
  200.     Totalr& = HiWord&(rInfo&)
  201.     FreeR& = LoWord(rInfo&)
  202.     GetFreeResources = FreeR& * 100 \ Totalr&
  203. End Function
  204. Function HiWord& (LongInt&)
  205.     Temp& = LongInt& \ &H10000
  206.     If Temp& < 0 Then Temp& = Temp& + &H10000
  207.     HiWord& = Temp&
  208. End Function
  209. Function LoWord& (LongInt&)
  210.     Temp& = LongInt& Mod &H10000
  211.     If Temp& < 0 Then Temp& = Temp& + &H10000
  212.     LoWord& = Temp&
  213. End Function
  214. Function Min (P1, P2)
  215.     If P1 < P2 Then Min = P1 Else Min = P2
  216. End Function
  217. Sub Quit_Click ()
  218.     Unload Wallchng
  219.     End
  220. End Sub
  221. Sub ResMemDisk ()
  222.   Static SpaceFree As Long
  223.   x = 3
  224.   SpaceFree = DiskInfo(x, 1)
  225.   Do While SpaceFree <> -1
  226.     disk(x) = Chr$(x + 64) + ": " + Format$((SpaceFree \ 1024) \ 1000) + "M free"
  227.     x = x + 1
  228.     If x > 5 Then
  229.     x = 5
  230.     End If
  231.     SpaceFree = DiskInfo(x, 1)
  232.   Loop
  233.   x = 3
  234.   Static OldFreeSpace As Long, FreeSpace As Long
  235.   FreeSpace = GetFreeSpace(0)
  236.   If OldFreeSpace <> FreeSpace Then
  237.     OldFreeSpace = FreeSpace
  238.     mem = "Free memory: " + Format$((FreeSpace \ 1024) \ 1000) + "M"
  239.   End If
  240.   TFree = Min(GetFreeResources("User"), GetFreeResources("GDI"))
  241.   If TFree <> OldTotal Then
  242.     OldTotal = TFree
  243.     res = "Free resources: " + Format$(TFree, "00") + "%"
  244.   End If
  245.   MyTime = Mid$(Time$, 1, 5)
  246.   If MyTime <> OldMyTime Then
  247.     OldMyTime = MyTime
  248.     Hours = Val(MyTime)
  249.     If Hours > 12 Then Mid$(MyTime, 1, 2) = Str$(Hours - 12)
  250.     tim = "Time:  " + MyTime
  251.   End If
  252. End Sub
  253. Sub timer1_timer ()
  254.     If combo1.text = " 5 Minutes" Then
  255.     timeloop = timeloop - 1
  256.     End If
  257.     If combo1.text = "30 Minutes" Then
  258.     timeloop = timeloop - 1
  259.     End If
  260.     If combo1.text = "30 Minutes" Then
  261.     If timeloop = 0 Then
  262.         If Called = "Y" Then
  263.         DirBMP2
  264.         Else
  265.         DirBMP
  266.         End If
  267.         WallPaper$ = WallPaperFile
  268.         SystemParametersInfo SPI_SETDESKWALLPAPER, 0, ByVal WallPaper$, SPIF_UPDATEINIFILE
  269.         timeloop = 30
  270.     End If
  271.     ElseIf combo1.text = " 5 Minutes" Then
  272.     If timeloop = 0 Then
  273.         If Called = "Y" Then
  274.         DirBMP2
  275.         Else
  276.         DirBMP
  277.         End If
  278.         WallPaper$ = WallPaperFile
  279.         SystemParametersInfo SPI_SETDESKWALLPAPER, 0, ByVal WallPaper$, SPIF_UPDATEINIFILE
  280.         timeloop = 5
  281.     End If
  282.     Else
  283.     If Called = "Y" Then
  284.         DirBMP2
  285.     Else
  286.         DirBMP
  287.     End If
  288.     WallPaper$ = WallPaperFile
  289.     SystemParametersInfo SPI_SETDESKWALLPAPER, 0, ByVal WallPaper$, SPIF_UPDATEINIFILE
  290.     End If
  291.   ResMemDisk
  292. End Sub
  293. Sub Timer2_Timer ()
  294.     Wallchng.icon = icon1.dragicon
  295. End Sub
  296. Sub Timer3_Timer ()
  297.     Wallchng.icon = icon2.dragicon
  298. End Sub
  299. Sub Timer4_Timer ()
  300.     Wallchng.icon = icon3.dragicon
  301.     If CapSwitch = "1" Then
  302.     Wallchng.caption = mem
  303.     CapSwitch = "2"
  304.     ElseIf CapSwitch = "2" Then
  305.     Wallchng.caption = res
  306.     CapSwitch = "3"
  307.     ElseIf CapSwitch = "3" Then
  308.     If disk(x) > "" Then
  309.         Wallchng.caption = disk(x)
  310.         x = x + 1
  311.         If x > 5 Then
  312.         x = 5
  313.         End If
  314.     Else
  315.         CapSwitch = "4"
  316.         x = 3
  317.     End If
  318.     ElseIf CapSwitch = "4" Then
  319.     Wallchng.caption = tim
  320.     CapSwitch = "1"
  321.     End If
  322. End Sub
  323. Sub Timer5_Timer ()
  324.     Wallchng.icon = icon4.dragicon
  325. End Sub
  326.